package edu.neepu;

public class Threa5 implements Runnable {
    private Thread t;
    private String threadName;

    Threa5(String name) {
        threadName = name;
        System.out.println("Creating " +  threadName );
    }
    test5 a = new test5();

    public void run() {
        System.out.println("Running " +  threadName );
        try {
            // 让线程睡眠一会
            a.go();
            Thread.sleep(200);
        }catch (Exception e) {
            System.out.println("Thread " +  threadName + " Wrong");
        }
        System.out.println("Thread " +  threadName + " exiting.");
    }

    public void start () {
        System.out.println("Starting " +  threadName );
        if (t == null) {
            t = new Thread (this, threadName);
            t.start ();
        }
    }
}
